<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>
        .weatcher{
            font-size: 32px;
            font-weight: bold;
        }
    </style>
</head>
<body>
    <div id="test"></div>
    <script src="./js/react.development.js" crossorigin></script> 
    <script src="./js/react-dom.development.js" crossorigin></script>
    <script src="./js/babel.min.js"></script>
    <script src="./js/prop-types.js"></script>
    <script type="text/babel">
        class Demo extends React.Component{
            state = {isHot: true}
            showData = () => {
                // alert(this.input.value)
                console.log()
            }
            changeWeather = () => {
                this.setState({
                    isHot: !this.state.isHot
                })
            }
            inputRef = (currentNode) => {
                this.input = currentNode;console.log("@",currentNode)
            }
            
            render(){
                const { isHot } = this.state
                return (
                    <div>
                        <h2>今天天气很{isHot?'炎热': '凉爽'}</h2>
                        <input ref={this.inputRef} type="text" placeholder="点击按钮提示" />
                        <button onClick={this.showData}>点我提示左侧的数据</button>
                        <button onClick={this.changeWeather}>点我切换天气</button>
                    </div>
                )
            }
        }

        ReactDOM.render(<Demo />,document.getElementById('test'))

        /**
         * 回调ref中回调执行次数的问题
         * 当直接写入内联回调函数时，会在dom更新时调用两次
         * react在更新dom时会先清空ref，然后再重新复制
         * 
        */
    </script>
</body>
</html>